﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
    public partial class Common : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(lithead.Text))
            {
                lithead.Text += GetJqueryRegisterScript();
                lithead.Text += GetJqueryUIRegisterScript();
                lithead.Text += GetFiaFrameRegisterScript();
                lithead.Text += GetEasyUiRegisterScript();
                lithead.Text += GetEasyUILocalRegisterScript();
            }
            string pagename =Request.CurrentExecutionFilePath.Remove(0, Request.ApplicationPath.Length + 1).Replace(".aspx", "");
            h_pagename.Value = pagename;
            if (!IsPostBack)
            {
                //如果是第一次加载，LoadCount为0.
                h_loadCount.Value = "0";
            }
            else
            {
                //如果不是第一次加载，LoadCount为10.
                h_loadCount.Value = "10";
            }
            if (Request.QueryString["savecookie"] == null || Request.QueryString["savecookie"] == "0")
            {
                h_savecookie.Value = false.ToString().ToLower();
            }
            else
            {
                h_savecookie.Value = true.ToString().ToLower();
            }
        }

        /// <summary>
        /// 注册jquery脚本
        /// </summary>
        /// <returns></returns>
        private string GetJqueryRegisterScript()
        {
            string script = "<script language=JavaScript src=\"" + System.Web.HttpContext.Current.Request.ApplicationPath + "/Javascript/jquery-1.5.2.min.js\" charset=\"utf-8\"></script>";
            return script;
        }

        /// <summary>
        /// 注册RIAFrame脚本
        /// </summary>
        /// <returns></returns>
        private string GetFiaFrameRegisterScript()
        {
            string script = "<script language=JavaScript src=\"" + System.Web.HttpContext.Current.Request.ApplicationPath + "/Javascript/RiaFrame_Base.js\" charset=\"utf-8\"></script>";
            return script;
        }

        /// <summary>
        /// 注册Jquery-UI脚本
        /// </summary>
        /// <returns></returns>
        private string GetJqueryUIRegisterScript()
        {
            string script = "<script language=JavaScript src=\"" + System.Web.HttpContext.Current.Request.ApplicationPath + "/Javascript/jquery-ui.min.js\" charset=\"utf-8\"></script>";
            return script;
        }

        /// <summary>
        /// 注册EasyUI脚本
        /// </summary>
        /// <returns></returns>
        private string GetEasyUiRegisterScript()
        {
            string script = "<script language=JavaScript src=\"" + System.Web.HttpContext.Current.Request.ApplicationPath + "/Easy_UI/jquery.easyui.min.js\" charset=\"utf-8\"></script>";
            return script;
        }
        /// <summary>
        /// 注册Easyui本地化脚本（zh-cn）
        /// </summary>
        /// <returns></returns>
        private string GetEasyUILocalRegisterScript()
        {
            string script = "<script language=JavaScript src=\"" + System.Web.HttpContext.Current.Request.ApplicationPath + "/Easy_UI/locale/easyui-lang-zh_CN.js\" charset=\"utf-8\"></script>";
            return script;
        }

    }
}